import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CouponVO, CouponForm, CouponQuery } from '@/api/kitchen/coupon/types';

/**
 * 查询用户的商家抵扣券列表
 * @param query
 * @returns {*}
 */

export const listCoupon = (query?: CouponQuery): AxiosPromise<CouponVO[]> => {
  return request({
    url: '/kitchen/coupon/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询用户的商家抵扣券详细
 * @param id
 */
export const getCoupon = (id: string | number): AxiosPromise<CouponVO> => {
  return request({
    url: '/kitchen/coupon/' + id,
    method: 'get'
  });
};

/**
 * 新增用户的商家抵扣券
 * @param data
 */
export const addCoupon = (data: CouponForm) => {
  return request({
    url: '/kitchen/coupon',
    method: 'post',
    data: data
  });
};

/**
 * 修改用户的商家抵扣券
 * @param data
 */
export const updateCoupon = (data: CouponForm) => {
  return request({
    url: '/kitchen/coupon',
    method: 'put',
    data: data
  });
};

/**
 * 删除用户的商家抵扣券
 * @param id
 */
export const delCoupon = (id: string | number | Array<string | number>) => {
  return request({
    url: '/kitchen/coupon/' + id,
    method: 'delete'
  });
};
